package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.HomeBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.GetDateTime;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.HomePageService;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

public class HomeActivity extends AppActivity
{
  private static String WEB_CONNECTION;
  private int BadUrls = 0;
  private int Blog = 1;
  private String alertString = "";
  private Bundle bundle = null;
  private SharedPreferences.Editor editor;
  private String equipName = "";
  private String equipType = "Android";
  private HomeBean f_HomeBean;
  private HomePageService f_HomePageService = null;
  private int isOnline = 0;
  private int limtUrls = 0;
  private int limtgame = 0;
  private LinearLayout linear_childuse;
  private LinearLayout linear_recentsoft;
  private LinearLayout linear_recentweb;
  private String lockstatus;
  private Intent mHomePageTurn;
  private String netstatus;
  private SharedPreferences preferences;
  private RelativeLayout relativeLayout_imp;
  private TextView textview_homepage_show;
  private String userId = "";
  private int usetime = 0;
  private ProgressDialog v_progressDialog = null;
  private TextView v_textview_blogtitle;
  private TextView v_textview_cut;
  private TextView v_textview_equipname_game;
  private TextView v_textview_equipname_url;
  private TextView v_textview_home_BadUrls;
  private TextView v_textview_home_CloseTime;
  private TextView v_textview_home_LimitGames;
  private TextView v_textview_home_LimitUrls;
  private TextView v_textview_home_UsedTime;
  private TextView v_textview_home_UsingGame;
  private TextView v_textview_home_UsingUrl;
  private TextView v_textview_home_boottime;
  private TextView v_textview_home_flow;
  private TextView v_textview_homepage_ipm;
  private TextView v_textview_lock;

  private void HomePageRefashListener()
  {
  }

  private void HomePageTurnListener()
  {
  }

  private void addListener()
  {
    HomePageTurnListener();
    HomePageRefashListener();
    showInfoImpListener();
    badurlListener();
    limturlListener();
    limtgameListener();
    quickCutListener();
    quickLockListener();
  }

  private void badurlListener()
  {
    this.v_textview_home_BadUrls.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new HomeActivity.HomeAsyncTask(HomeActivity.this).execute(new String[] { "badurl" });
      }
    });
  }

  private String bgInitHomeBean()
  {
    try
    {
      this.f_HomeBean = this.f_HomePageService.getHomeBeanInfo(this.userId, this.equipName, this);
      return "";
    }
    catch (IOException localIOException)
    {
      this.alertString = getString(2131427525);
      return "";
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      this.alertString = getString(2131427525);
      return "";
    }
    catch (TimeOutException localTimeOutException)
    {
      this.alertString = getString(2131427526);
      return "";
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
      this.alertString = "没有连接到网络";
    }
    return "";
  }

  private void bgShowHomeBean(String paramString)
  {
    if (this.f_HomeBean != null)
    {
      if ((this.f_HomeBean.getUsingUrl() != null) && (!this.f_HomeBean.getUsingUrl().equals("")))
        this.v_textview_home_UsingUrl.setText(this.f_HomeBean.getUsingUrl());
      if ((this.f_HomeBean.getUsingGame() != null) && (!this.f_HomeBean.getUsingGame().equals("")))
        this.v_textview_home_UsingGame.setText(this.f_HomeBean.getUsingGame());
      if ((this.f_HomeBean.getIsOnline() != null) && (!this.f_HomeBean.getIsOnline().equals("")))
      {
        if (Integer.parseInt(this.f_HomeBean.getIsOnline()) == 0)
        {
          this.v_textview_home_UsedTime.setTextColor(-65536);
          this.isOnline = 0;
        }
      }
      else
      {
        if ((this.f_HomeBean.getNetworkStatus() != null) && (!this.f_HomeBean.getNetworkStatus().equals("")))
        {
          if (Integer.parseInt(this.f_HomeBean.getNetworkStatus()) != 3)
            break label913;
          this.editor.putString("cutnet", "connect");
          this.editor.commit();
          this.v_textview_cut.setText(getString(2131427677));
          turnGreen(this.v_textview_cut);
        }
        label225: if ((this.f_HomeBean.getScreenStatus() != null) && (!this.f_HomeBean.getScreenStatus().equals("")))
        {
          if (Integer.parseInt(this.f_HomeBean.getScreenStatus()) != 2)
            break label964;
          this.editor.putString("lockscreen", "open");
          this.editor.commit();
          this.v_textview_lock.setText(getString(2131427681));
          turnGreen(this.v_textview_lock);
        }
      }
      while (true)
      {
        if ((this.f_HomeBean.getBootTime() != null) && (!this.f_HomeBean.getBootTime().equals("")))
          this.v_textview_home_boottime.setText(this.f_HomeBean.getBootTime());
        if ((this.f_HomeBean.getCloseTime() != null) && (!this.f_HomeBean.getCloseTime().equals("")))
          this.v_textview_home_CloseTime.setText(this.f_HomeBean.getCloseTime());
        if ((this.f_HomeBean.getUsedTime() != null) && (!this.f_HomeBean.getUsedTime().equals("")))
        {
          this.usetime = Integer.valueOf(this.f_HomeBean.getUsedTime()).intValue();
          String str = Math.round(this.usetime / 60) + " " + getString(2131427914) + " ";
          if (this.usetime % 60 != 0)
            str = str + this.usetime % 60 + " " + getString(2131427915);
          this.v_textview_home_UsedTime.setText(str);
        }
        this.f_HomeBean.getFlow();
        if (this.f_HomeBean.getBadUrls() != null)
        {
          this.BadUrls = Integer.valueOf(this.f_HomeBean.getBadUrls()).intValue();
          this.v_textview_home_BadUrls.setText(getString(2131427687) + " " + this.BadUrls + " " + getString(2131427691));
        }
        if (this.f_HomeBean.getLimitUrls() != null)
        {
          this.limtUrls = Integer.valueOf(this.f_HomeBean.getLimitUrls()).intValue();
          this.v_textview_home_LimitUrls.setText(getString(2131427688) + " " + this.limtUrls + " " + getString(2131427691));
        }
        if (this.f_HomeBean.getLimitGames() != null)
        {
          this.limtgame = Integer.valueOf(this.f_HomeBean.getLimitGames()).intValue();
          this.v_textview_home_LimitGames.setText(getString(2131427689) + " " + this.limtgame + " " + getString(2131427691));
        }
        if ((this.limtgame == 0) && (this.limtUrls == 0) && (this.BadUrls == 0))
          break label1015;
        this.textview_homepage_show.setVisibility(8);
        this.v_textview_homepage_ipm.setVisibility(0);
        this.v_textview_homepage_ipm.setText(getString(2131427690) + (this.limtgame + this.limtUrls + this.BadUrls) + getString(2131427691));
        return;
        this.isOnline = 1;
        this.v_textview_home_UsedTime.setTextColor(getResources().getColor(2131230732));
        break;
        label913: this.editor.putString("cutnet", "cut");
        this.editor.commit();
        this.v_textview_cut.setText(getString(2131427673));
        turnWhite(this.v_textview_cut);
        break label225;
        label964: this.editor.putString("lockscreen", "lock");
        this.editor.commit();
        this.v_textview_lock.setText(getString(2131427680));
        turnWhite(this.v_textview_lock);
      }
      label1015: this.textview_homepage_show.setVisibility(0);
      this.v_textview_homepage_ipm.setVisibility(8);
      return;
    }
    alertMessage(this.alertString);
  }

  private void blogTitleListener()
  {
    this.v_textview_blogtitle.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
      }
    });
  }

  private void createOrShowDialog()
  {
    if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
    {
      this.v_progressDialog = new ProgressDialog(this);
      this.v_progressDialog.setMessage(getString(2131427516));
      this.v_progressDialog.setCancelable(true);
      this.v_progressDialog.show();
    }
  }

  private void initActionBar()
  {
    setBarTitle(getResources().getString(2131427335));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        HomeActivity.this.finish();
      }
    });
    setBarHomeDrawable(getResources().getDrawable(2130838067));
    setBarHomeOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new HomeActivity.HomeAsyncTask(HomeActivity.this).execute(new String[] { "refash" });
      }
    });
  }

  private void initView()
  {
    WEB_CONNECTION = getResources().getString(2131427354);
    this.preferences = getSharedPreferences("cutnet", 0);
    this.editor = this.preferences.edit();
    this.equipType = getSharedPreferences("equipname", 0).getString("equiptype", "Android");
    this.v_textview_homepage_ipm = ((TextView)findViewById(2131493234));
    this.textview_homepage_show = ((TextView)findViewById(2131493233));
    this.v_textview_home_BadUrls = ((TextView)findViewById(2131493237));
    this.v_textview_home_LimitUrls = ((TextView)findViewById(2131493239));
    this.v_textview_home_LimitGames = ((TextView)findViewById(2131493240));
    this.v_textview_blogtitle = ((TextView)findViewById(2131493251));
    this.relativeLayout_imp = ((RelativeLayout)findViewById(2131493235));
    this.v_textview_home_UsingUrl = ((TextView)findViewById(2131493246));
    this.v_textview_home_UsingGame = ((TextView)findViewById(2131493248));
    this.v_textview_home_boottime = ((TextView)findViewById(2131493243));
    this.v_textview_home_CloseTime = ((TextView)findViewById(2131493244));
    this.v_textview_home_UsedTime = ((TextView)findViewById(2131493242));
    this.v_textview_cut = ((TextView)findViewById(2131493249));
    this.v_textview_lock = ((TextView)findViewById(2131493250));
    this.linear_childuse = ((LinearLayout)findViewById(2131493241));
    this.linear_recentweb = ((LinearLayout)findViewById(2131493245));
    this.linear_recentsoft = ((LinearLayout)findViewById(2131493247));
    this.f_HomePageService = new HomePageService();
    getSharedPreferences("equipname", 0);
    this.preferences.getString("nick", this.equipName);
    RqSP localRqSP = new RqSP();
    this.equipName = localRqSP.getLgDevId(this);
    this.userId = localRqSP.getLgDevAccount(this);
    this.bundle = new Bundle();
    this.v_textview_cut.setText(getString(2131427677));
    this.v_textview_cut.setTextColor(-1);
    this.v_textview_lock.setText(getString(2131427681));
    this.v_textview_lock.setTextColor(-1);
  }

  private void limtgameListener()
  {
    this.v_textview_home_LimitGames.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new HomeActivity.HomeAsyncTask(HomeActivity.this).execute(new String[] { "limgame" });
      }
    });
  }

  private void limturlListener()
  {
    this.v_textview_home_LimitUrls.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new HomeActivity.HomeAsyncTask(HomeActivity.this).execute(new String[] { "limturl" });
      }
    });
  }

  private void linearItemClickListener()
  {
    this.linear_childuse.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        HomeActivity.this.IntentActivity(HomeActivity.this, TimeFunctionAtivity.class);
      }
    });
    this.linear_recentweb.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        HomeActivity.this.bundle = new Bundle();
        HomeActivity.this.bundle.putString("webType", "all");
        HomeActivity.this.bundle.putString("date", GetDateTime.getDate());
        HomeActivity.this.IntentActivity(HomeActivity.this, RecordWebUrlActivity.class, HomeActivity.this.bundle);
      }
    });
    this.linear_recentsoft.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        HomeActivity.this.bundle = new Bundle();
        HomeActivity.this.bundle.putString("webType", "all");
        HomeActivity.this.bundle.putString("date", GetDateTime.getDate());
        HomeActivity.this.IntentActivity(HomeActivity.this, RecordSoftUrlActivity.class, HomeActivity.this.bundle);
      }
    });
  }

  private void prepareIntent()
  {
    this.mHomePageTurn = new Intent(this, EquipSelectAtivity.class);
  }

  private void quickCutListener()
  {
    this.v_textview_cut.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new DBHelper(HomeActivity.this).insertModuleAccess(Global.ManageUserName, Global.getIMEI(HomeActivity.this), HomeActivity.this.getResources().getStringArray(2131165189)[0], HomeActivity.this.getResources().getStringArray(2131165189)[1]);
        HomeActivity.HomeAsyncTask localHomeAsyncTask = new HomeActivity.HomeAsyncTask(HomeActivity.this);
        HomeActivity.this.netstatus = HomeActivity.this.preferences.getString("cutnet", "");
        if (HomeActivity.this.netstatus.equals("cut"))
          localHomeAsyncTask.execute(new String[] { "connect" });
        while ((!HomeActivity.this.netstatus.equals("connect")) && (!HomeActivity.this.netstatus.trim().equals("")))
          return;
        if (HomeActivity.this.isOnline == 1)
        {
          localHomeAsyncTask.execute(new String[] { "cut" });
          return;
        }
        HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427692));
      }
    });
  }

  private void quickLockListener()
  {
    this.v_textview_lock.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new DBHelper(HomeActivity.this).insertModuleAccess(Global.ManageUserName, Global.getIMEI(HomeActivity.this), HomeActivity.this.getResources().getStringArray(2131165190)[0], HomeActivity.this.getResources().getStringArray(2131165190)[1]);
        HomeActivity.HomeAsyncTask localHomeAsyncTask = new HomeActivity.HomeAsyncTask(HomeActivity.this);
        HomeActivity.this.lockstatus = HomeActivity.this.preferences.getString("lockscreen", "");
        if (HomeActivity.this.lockstatus.equals("lock"))
          localHomeAsyncTask.execute(new String[] { "open" });
        while ((!HomeActivity.this.lockstatus.equals("open")) && (!HomeActivity.this.lockstatus.trim().equals("")))
          return;
        if (HomeActivity.this.isOnline == 1)
        {
          localHomeAsyncTask.execute(new String[] { "lock" });
          return;
        }
        HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427692));
      }
    });
  }

  private String quickSubmit(String paramString)
  {
    this.alertString = "";
    try
    {
      this.alertString = this.f_HomePageService.quickSubmit(this.userId, this.equipName, paramString, this);
      return this.alertString;
    }
    catch (IOException localIOException)
    {
      while (true)
        this.alertString = getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        this.alertString = getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        this.alertString = getString(2131427526);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
      {
        localNotFoundNetWorkException.getClass();
        this.alertString = "没有连接到网络";
      }
    }
  }

  private void showInfoImpListener()
  {
    this.v_textview_homepage_ipm.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        if (HomeActivity.this.Blog == 1)
        {
          HomeActivity.this.relativeLayout_imp.setVisibility(0);
          HomeActivity.this.v_textview_homepage_ipm.setBackgroundResource(2130837734);
          HomeActivity.this.Blog = 2;
          return;
        }
        HomeActivity.this.relativeLayout_imp.setVisibility(8);
        HomeActivity.this.v_textview_homepage_ipm.setBackgroundResource(2130837731);
        HomeActivity.this.Blog = 1;
      }
    });
  }

  private void showView()
  {
    new HomeAsyncTask().execute(new String[] { "init" });
  }

  private void turnGreen(TextView paramTextView)
  {
    paramTextView.setTextColor(-1);
    paramTextView.setBackgroundDrawable(getResources().getDrawable(2130837632));
  }

  private void turnWhite(TextView paramTextView)
  {
    paramTextView.setTextColor(-16777216);
    paramTextView.setBackgroundDrawable(getResources().getDrawable(2130837636));
  }

  private void visitEsurfing()
  {
    startActivity(new Intent("android.intent.action.VIEW", Uri.parse(WEB_CONNECTION)));
  }

  protected void backKeyCallBack()
  {
    super.backKeyCallBack();
    finish();
  }

  public void onBackPressed()
  {
    super.onBackPressed();
    finish();
    Global.isManageLogin = false;
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903140);
    initActionBar();
    initView();
    addListener();
    linearItemClickListener();
    prepareIntent();
  }

  protected void onResume()
  {
    super.onResume();
    showView();
  }

  public class HomeAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public HomeAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("init"))
        return HomeActivity.this.bgInitHomeBean();
      if (this.method.equals("refash"))
        return HomeActivity.this.bgInitHomeBean();
      if (this.method.equals("badurl"))
        HomeActivity.this.bundle.putString("logtype", "badurl");
      do
      {
        while (true)
        {
          return "";
          if (this.method.equals("limturl"))
          {
            HomeActivity.this.bundle.putString("logtype", "limturl");
          }
          else
          {
            if (!this.method.equals("limgame"))
              break;
            HomeActivity.this.bundle.putString("logtype", "limgame");
          }
        }
        if (this.method.equals("cut"))
          return HomeActivity.this.quickSubmit("1");
        if (this.method.equals("connect"))
          return HomeActivity.this.quickSubmit("3");
        if (this.method.equals("open"))
          return HomeActivity.this.quickSubmit("2");
      }
      while (!this.method.equals("lock"));
      return HomeActivity.this.quickSubmit("0");
    }

    protected void onPostExecute(String paramString)
    {
      if ((this.method.equals("init")) || (this.method.equals("refash")))
        HomeActivity.this.bgShowHomeBean(paramString);
      try
      {
        while (true)
        {
          HomeActivity.this.v_progressDialog.dismiss();
          return;
          if (this.method.equals("cut"))
          {
            if (paramString.equals("0"))
            {
              HomeActivity.this.editor.putString("cutnet", "cut");
              HomeActivity.this.editor.commit();
              if ("PC".equalsIgnoreCase(HomeActivity.this.equipType))
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427671));
              while (true)
              {
                HomeActivity.this.v_textview_cut.setText(HomeActivity.this.getString(2131427673));
                HomeActivity.this.turnWhite(HomeActivity.this.v_textview_cut);
                break;
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427672));
              }
            }
            HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427674));
          }
          else if (this.method.equals("connect"))
          {
            if (paramString.equals("0"))
            {
              HomeActivity.this.editor.putString("cutnet", "connect");
              HomeActivity.this.editor.commit();
              if ("PC".equalsIgnoreCase(HomeActivity.this.equipType))
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427675));
              while (true)
              {
                HomeActivity.this.v_textview_cut.setText(HomeActivity.this.getString(2131427677));
                HomeActivity.this.turnGreen(HomeActivity.this.v_textview_cut);
                break;
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427676));
              }
            }
            HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427674));
          }
          else if (this.method.equals("lock"))
          {
            if (paramString.equals("0"))
            {
              HomeActivity.this.editor.putString("lockscreen", "lock");
              HomeActivity.this.editor.commit();
              if ("PC".equalsIgnoreCase(HomeActivity.this.equipType))
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427678));
              while (true)
              {
                HomeActivity.this.v_textview_lock.setText(HomeActivity.this.getString(2131427680));
                HomeActivity.this.turnWhite(HomeActivity.this.v_textview_lock);
                break;
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427679));
              }
            }
            HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427674));
          }
          else if (this.method.equals("open"))
          {
            if (paramString.equals("0"))
            {
              HomeActivity.this.editor.putString("lockscreen", "open");
              HomeActivity.this.editor.commit();
              if ("PC".equalsIgnoreCase(HomeActivity.this.equipType))
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427682));
              while (true)
              {
                HomeActivity.this.v_textview_lock.setText(HomeActivity.this.getString(2131427681));
                HomeActivity.this.turnGreen(HomeActivity.this.v_textview_lock);
                break;
                HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427683));
              }
            }
            HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427674));
          }
          else if (this.method.equals("badurl"))
          {
            if (HomeActivity.this.BadUrls != 0)
              HomeActivity.this.IntentActivity(HomeActivity.this, ImprotentInfoActivity.class, HomeActivity.this.bundle);
            else
              HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427684));
          }
          else if (this.method.equals("limturl"))
          {
            if (HomeActivity.this.limtUrls != 0)
              HomeActivity.this.IntentActivity(HomeActivity.this, ImprotentInfoActivity.class, HomeActivity.this.bundle);
            else
              HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427684));
          }
          else if (this.method.equals("limgame"))
          {
            if (HomeActivity.this.limtgame != 0)
              HomeActivity.this.IntentActivity(HomeActivity.this, ImprotentInfoActivity.class, HomeActivity.this.bundle);
            else
              HomeActivity.this.alertMessage(HomeActivity.this.getString(2131427684));
          }
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }

    protected void onPreExecute()
    {
      HomeActivity.this.createOrShowDialog();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.HomeActivity
 * JD-Core Version:    0.6.2
 */